package com.zhoust.fastdome.config;

import com.zhoust.fastdome.adapter.LogInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author zhoust
 * @Date 2021/9/23 11:19
 * @Desc WebMVC 配置
 */
@Configuration
public class WebAdapterConfig implements WebMvcConfigurer {

    private final LogInterceptor interceptor;

    public WebAdapterConfig(LogInterceptor interceptor) {
        this.interceptor = interceptor;
    }

    /**
     * 注册拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor).addPathPatterns("/**");
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
